home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / cxref_1_4a.lha / cpp / cexp.c < prev    next >
C/C++ Source or Header  |  1997-04-25  |  52KB  |  1,902 lines

  1.  
  2. /*  A Bison parser, made from cexp.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    INT    258
  8. #define    CHAR    259
  9. #define    NAME    260
  10. #define    ERROR    261
  11. #define    OR    262
  12. #define    AND    263
  13. #define    EQUAL    264
  14. #define    NOTEQUAL    265
  15. #define    LEQ    266
  16. #define    GEQ    267
  17. #define    LSH    268
  18. #define    RSH    269
  19. #define    UNARY    270
  20.  
  21.  
  22. #include "config.h"
  23. #include <setjmp.h>
  24. /* #define YYDEBUG 1 */
  25.  
  26. #ifdef MULTIBYTE_CHARS
  27. #include <stdlib.h>
  28. #include <locale.h>
  29. #endif
  30.  
  31. #include <stdio.h>
  32.  
  33. typedef unsigned char U_CHAR;
  34.  
  35. /* This is used for communicating lists of keywords with cccp.c.  */
  36. struct arglist {
  37.   struct arglist *next;
  38.   U_CHAR *name;
  39.   int length;
  40.   int argno;
  41. };
  42.  
  43. /* Define a generic NULL if one hasn't already been defined.  */
  44.  
  45. #ifndef NULL
  46. #define NULL 0
  47. #endif
  48.  
  49. #ifndef GENERIC_PTR
  50. #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
  51. #define GENERIC_PTR void *
  52. #else
  53. #define GENERIC_PTR char *
  54. #endif
  55. #endif
  56.  
  57. /* Find the largest host integer type and set its size and type.  */
  58.  
  59. #ifndef HOST_BITS_PER_WIDE_INT
  60.  
  61. #if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
  62. #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
  63. #define HOST_WIDE_INT long
  64. #else
  65. #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
  66. #define HOST_WIDE_INT int
  67. #endif
  68.  
  69. #endif
  70.  
  71. #ifndef NULL_PTR
  72. #define NULL_PTR ((GENERIC_PTR)0)
  73. #endif
  74.  
  75. int yylex ();
  76. void yyerror ();
  77. HOST_WIDE_INT expression_value;
  78.  
  79. static jmp_buf parse_return_error;
  80.  
  81. /* Nonzero means count most punctuation as part of a name.  */
  82. static int keyword_parsing = 0;
  83.  
  84. /* Nonzero means do not evaluate this expression.
  85.    This is a count, since unevaluated expressions can nest.  */
  86. static int skip_evaluation;
  87.  
  88. /* some external tables of character types */
  89. extern unsigned char is_idstart[], is_idchar[], is_hor_space[];
  90.  
  91. extern char *xmalloc ();
  92.  
  93. /* Flag for -pedantic.  */
  94. extern int pedantic;
  95.  
  96. /* Flag for -traditional.  */
  97. extern int traditional;
  98.  
  99. #ifndef CHAR_TYPE_SIZE
  100. #define CHAR_TYPE_SIZE BITS_PER_UNIT
  101. #endif
  102.  
  103. #ifndef INT_TYPE_SIZE
  104. #define INT_TYPE_SIZE BITS_PER_WORD
  105. #endif
  106.  
  107. #ifndef LONG_TYPE_SIZE
  108. #define LONG_TYPE_SIZE BITS_PER_WORD
  109. #endif
  110.  
  111. #ifndef WCHAR_TYPE_SIZE
  112. #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
  113. #endif
  114.  
  115. #ifndef MAX_CHAR_TYPE_SIZE
  116. #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
  117. #endif
  118.  
  119. #ifndef MAX_INT_TYPE_SIZE
  120. #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
  121. #endif
  122.  
  123. #ifndef MAX_LONG_TYPE_SIZE
  124. #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
  125. #endif
  126.  
  127. #ifndef MAX_WCHAR_TYPE_SIZE
  128. #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
  129. #endif
  130.  
  131. /* Yield nonzero if adding two numbers with A's and B's signs can yield a
  132.    number with SUM's sign, where A, B, and SUM are all C integers.  */
  133. #define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0)
  134.  
  135. static void integer_overflow ();
  136. static long left_shift ();
  137. static long right_shift ();
  138.  
  139. typedef union {
  140.   struct constant {long value; int unsignedp;} integer;
  141.   struct name {U_CHAR *address; int length;} name;
  142.   struct arglist *keywords;
  143. } YYSTYPE;
  144.  
  145. #ifndef YYLTYPE
  146. typedef
  147.   struct yyltype
  148.     {
  149.       int timestamp;
  150.       int first_line;
  151.       int first_column;
  152.       int last_line;
  153.       int last_column;
  154.       char *text;
  155.    }
  156.   yyltype;
  157.  
  158. #define YYLTYPE yyltype
  159. #endif
  160.  
  161. #include <stdio.h>
  162.  
  163. #ifndef __cplusplus
  164. #ifndef __STDC__
  165. #define const
  166. #endif
  167. #endif
  168.  
  169.  
  170.  
  171. #define    YYFINAL        77
  172. #define    YYFLAG        -32768
  173. #define    YYNTBASE    34
  174.  
  175. #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43)
  176.  
  177. static const char yytranslate[] = {     0,
  178.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  179.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  180.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  181.      2,     2,    29,     2,    31,     2,    27,    14,     2,    32,
  182.     33,    25,    23,     9,    24,     2,    26,     2,     2,     2,
  183.      2,     2,     2,     2,     2,     2,     2,     8,     2,    17,
  184.      2,    18,     7,     2,     2,     2,     2,     2,     2,     2,
  185.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  186.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  187.      2,     2,     2,    13,     2,     2,     2,     2,     2,     2,
  188.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  189.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  190.      2,     2,     2,    12,     2,    30,     2,     2,     2,     2,
  191.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  192.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  193.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  194.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  195.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  196.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  197.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  198.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  199.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  200.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  201.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  202.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  203.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  204.      6,    10,    11,    15,    16,    19,    20,    21,    22,    28
  205. };
  206.  
  207. #if YYDEBUG != 0
  208. static const short yyprhs[] = {     0,
  209.      0,     2,     4,     8,    11,    14,    17,    20,    23,    24,
  210.     31,    35,    39,    43,    47,    51,    55,    59,    63,    67,
  211.     71,    75,    79,    83,    87,    91,    95,    99,   100,   105,
  212.    106,   111,   112,   113,   121,   123,   125,   127,   128,   133
  213. };
  214.  
  215. static const short yyrhs[] = {    35,
  216.      0,    36,     0,    35,     9,    36,     0,    24,    36,     0,
  217.     29,    36,     0,    23,    36,     0,    30,    36,     0,    31,
  218.      5,     0,     0,    31,     5,    37,    32,    42,    33,     0,
  219.     32,    35,    33,     0,    36,    25,    36,     0,    36,    26,
  220.     36,     0,    36,    27,    36,     0,    36,    23,    36,     0,
  221.     36,    24,    36,     0,    36,    21,    36,     0,    36,    22,
  222.     36,     0,    36,    15,    36,     0,    36,    16,    36,     0,
  223.     36,    19,    36,     0,    36,    20,    36,     0,    36,    17,
  224.     36,     0,    36,    18,    36,     0,    36,    14,    36,     0,
  225.     36,    13,    36,     0,    36,    12,    36,     0,     0,    36,
  226.     11,    38,    36,     0,     0,    36,    10,    39,    36,     0,
  227.      0,     0,    36,     7,    40,    36,     8,    41,    36,     0,
  228.      3,     0,     4,     0,     5,     0,     0,    32,    42,    33,
  229.     42,     0,     5,    42,     0
  230. };
  231.  
  232. #endif
  233.  
  234. #if YYDEBUG != 0
  235. static const short yyrline[] = { 0,
  236.    176,   181,   182,   189,   194,   197,   199,   202,   206,   208,
  237.    213,   218,   230,   246,   258,   265,   272,   278,   284,   287,
  238.    290,   296,   302,   308,   314,   317,   320,   323,   326,   329,
  239.    332,   335,   337,   340,   343,   345,   347,   352,   354,   367
  240. };
  241.  
  242. static const char * const yytname[] = {   "$","error","$illegal.","INT","CHAR",
  243. "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
  244. "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
  245. "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords",
  246. ""
  247. };
  248. #endif
  249.  
  250. static const short yyr1[] = {     0,
  251.     34,    35,    35,    36,    36,    36,    36,    36,    37,    36,
  252.     36,    36,    36,    36,    36,    36,    36,    36,    36,    36,
  253.     36,    36,    36,    36,    36,    36,    36,    38,    36,    39,
  254.     36,    40,    41,    36,    36,    36,    36,    42,    42,    42
  255. };
  256.  
  257. static const short yyr2[] = {     0,
  258.      1,     1,     3,     2,     2,     2,     2,     2,     0,     6,
  259.      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
  260.      3,     3,     3,     3,     3,     3,     3,     0,     4,     0,
  261.      4,     0,     0,     7,     1,     1,     1,     0,     4,     2
  262. };
  263.  
  264. static const short yydefact[] = {     0,
  265.     35,    36,    37,     0,     0,     0,     0,     0,     0,     1,
  266.      2,     6,